package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoInformationMapTitle;
import com.muyu.danmo.service.IDanmoInformationMapTitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 相关星图标题Controller
 *
 * @author kunzong
 * @date 2024-12-09
 */
@RestController
@RequestMapping("/DanmoInformationMapTitle")
public class DanmoInformationMapTitleController extends BaseController {
    @Autowired
    private IDanmoInformationMapTitleService danmoInformationMapTitleService;

    /**
     * 查询相关星图标题列表
     */
//    @RequiresPermissions("system:DanmoInformationMapTitle:list")
    @GetMapping("/list")
    public Result list(DanmoInformationMapTitle danmoInformationMapTitle) {
        startPage();
        List<DanmoInformationMapTitle> list = danmoInformationMapTitleService.selectDanmoInformationMapTitleList(danmoInformationMapTitle);
        return getDataTable(list);
    }

    /**
     * 导出相关星图标题列表
     */
//    @RequiresPermissions("system:DanmoInformationMapTitle:export")
    @Log(title = "相关星图标题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoInformationMapTitle danmoInformationMapTitle) {
        List<DanmoInformationMapTitle> list = danmoInformationMapTitleService.selectDanmoInformationMapTitleList(danmoInformationMapTitle);
        ExcelUtil<DanmoInformationMapTitle> util = new ExcelUtil<DanmoInformationMapTitle>(DanmoInformationMapTitle.class);
        util.exportExcel(response, list, "相关星图标题数据");
    }

    /**
     * 获取相关星图标题详细信息
     */
//    @RequiresPermissions("system:DanmoInformationMapTitle:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id) {
        return Result.success(danmoInformationMapTitleService.selectDanmoInformationMapTitleById(id));
    }

    /**
     * 新增相关星图标题
     */
//    @RequiresPermissions("system:DanmoInformationMapTitle:add")
    @Log(title = "相关星图标题", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoInformationMapTitle danmoInformationMapTitle) {
        return Result.success(danmoInformationMapTitleService.insertDanmoInformationMapTitle(danmoInformationMapTitle));
    }

    /**
     * 修改相关星图标题
     */
//    @RequiresPermissions("system:DanmoInformationMapTitle:edit")
    @Log(title = "相关星图标题", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoInformationMapTitle danmoInformationMapTitle) {
        return Result.success(danmoInformationMapTitleService.updateDanmoInformationMapTitle(danmoInformationMapTitle));
    }

    /**
     * 删除相关星图标题
     */
//    @RequiresPermissions("system:DanmoInformationMapTitle:remove")
    @Log(title = "相关星图标题", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids) {
        return Result.success(danmoInformationMapTitleService.deleteDanmoInformationMapTitleByIds(ids));
    }
}
